<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular.js"></script>
	</head>

	<body>
		<div ng-app="myApp">
			<div ng-controller="MyController">
				<input ng-model="to" type="email" placeholder="Recipient" />
				<textarea ng-model="emailBody"></textarea>
				<pre>{{ previewText }}</pre>
			</div>
		</div>
	</body>

</html>
<script>
	var app = angular.module('myApp', []);
	app.controller('MyController',
		function($scope, $interpolate) {
			$scope.to = 'ari@fullstack.io';
			$scope.emailBody = 'Hello {{ to }},\n\nMy name is Ari toow!';
			// Set up a watch
			$scope.$watch('emailBody', function(body) {
				if (body) {
					var template = $interpolate(body);
					$scope.previewText =
						template({
							to: $scope.to
						});
				}
			});
			$scope.$watch('to', function(body) {
				if (body) {
					var template = $interpolate(body);
					$scope.previewText =
						template({
							to: $scope.to,
							emailBody:$scope.emailBody
						});
				}
			});
		});
</script>